<?php
/**
 * 
 * @name 控制器底层文件
 * @author ChunYang.Jiang<chunyang@staff.sina.com.cn>
 * @copyright sina
 *
 */
class Controller
{
	public $tpl = NULL;
	public function __construct()
	{
		
	}
	
	/* 
	 * 等同于tpl->assign
	 */
	public function assign($var, $val)
	{
		View::assign($var, $val);
	}
	
	/*
	 * 等同于$tpl->display 
	 */
	public function display($tpl_name)
	{
		View::display('Index/' . $tpl_name . '.php');
		exit();
	}
	/*
	 * 等同于$tpl->fetch 
	 */
	public function fetch($tpl_name)
	{
		return View::fetch($tpl_name);
	}
	
	public function Show()
	{
		$this->NotFound();
	}
	
	/*
	 * 缺省页面
	 */
	public function NotFound()
	{
		View::display('Controller/NotFound.html');
	}
	
	public function __call($name, $arguments)
	{
		$this->NotFound();
	}
	
	public function __get($name)
	{
		$this->NotFound();
	}
	
	private function indexAct()
	{
		if (isset($_GET['cid']) && $_GET['cid']){
			$this->assign('cid', $_GET['cid']);
		}else{
			$this->assign('cid', 0);
		}
		
		$configs = ConfigModel::getList();
		foreach ($configs as $item){
			$tmpConfig[$item['name']] = $item['value'];
		}
		$this->picArticle();
		$this->getCatalogList();
		
		$this->assign('config', $tmpConfig);
	}
	
}